﻿<script type="text/javascript" src="~/RoadFlowResources/scripts/formDesigner/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="~/RoadFlowResources/scripts/formDesigner/common.js"></script>
<script id="container" type="text/plain">
    @Html.Raw(ViewData["html"])
</script>
<textarea id="editor1" cols="1" rows="1"></textarea>
<script type="text/javascript">
    var query = '@Html.Raw(ViewData["query"])';
    var isNewForm = '1' == '@ViewData["isNewForm"]';
    var typeId = '@ViewData["typeId"]';
    var formAttributeJSON = @Html.Raw(ViewData["attr"]);
    var currentSelectEditorElement = null; //保存编辑器ckeditor中当前焦点对象
    var formEventsJSON = @Html.Raw(ViewData["events"]);
    var dbconnOptions = '@Html.Raw(ViewData["dbconnOptions"])';//数据库连接option选项
    var formSubtabsJSON = @Html.Raw(ViewData["subtable"]);
    var ckEditor;
    $(window).load(function () {
        ckEditor = CKEDITOR.replace('editor1', {
            allowedContent: true,
            entities_greek: true,
            height: $(window).height()-128,
            contentsCss:"/RoadFlowResources/scripts/flowRun/common.css",
            filebrowserImageUploadUrl: '/RoadFlowCore/Controls/SaveCKEditorFiles',
            toolbarGroups : [
                { name: 'document', groups: [ 'mode', 'document', 'doctools' ] },
                { name: 'clipboard', groups: [ 'clipboard', 'undo' ] },
                { name: 'editing', groups: [ 'find', 'selection', 'spellchecker', 'editing' ] },
                { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ] },
                { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi', 'paragraph' ] },
                { name: 'links', groups: [ 'links' ] },
                { name: 'insert', groups: [ 'insert' ] },
                '/',
                { name: 'styles', groups: [ 'styles' ] },
                { name: 'colors', groups: [ 'colors' ] },
                { name: 'tools', groups: [ 'tools' ] },
                { name: 'others', groups: [ 'others' ] },
                { name: 'rf_plugins', groups: ['rf_plugins'] },
                { name: 'about', groups: [ 'about' ] }
            ]
        });

        CKEDITOR.on('instanceReady', function (event) {
            var editor = event.editor;
            setTimeout(function () {
                if (!editor.element) {
                    setTimeout(arguments.callee, 100);
                    return;
                }
                event.removeListener('instanceReady', this.callee);
                if (editor.name == 'editor1') {
                    //var command = editor.getCommand('maximize');
                    //command.exec();
                    //如果是新建表单，打开设计器时直接打开表单属性窗口
                    if(isNewForm){
                        var command = editor.getCommand('rf_attribute');
                        command.exec();
                    }
                }
            }, 0);
        }, null, null, 9999);
        ckEditor.setData($("#container").html());
    });

</script>